package com.beauty.logistics.dto;

import com.beauty.logistics.entity.Carrier;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CarrierResponse {
    
    private Long id;
    private String name;
    private String code;
    private String contactPerson;
    private String contactEmail;
    private String contactPhone;
    private String trackingUrlTemplate;
    private String apiCredentials;
    private Boolean isActive;
    private String supportedCountries;
    private String serviceOptions;
    private LocalDateTime createdAt;
    private LocalDateTime updatedAt;
    
    public static CarrierResponse fromEntity(Carrier carrier) {
        if (carrier == null) {
            return null;
        }
        
        return CarrierResponse.builder()
                .id(carrier.getId())
                .name(carrier.getName())
                .code(carrier.getCode())
                .contactPerson(carrier.getContactPerson())
                .contactEmail(carrier.getContactEmail())
                .contactPhone(carrier.getContactPhone())
                .trackingUrlTemplate(carrier.getTrackingUrlTemplate())
                .apiCredentials(carrier.getApiCredentials())
                .isActive(carrier.getIsActive())
                .supportedCountries(carrier.getSupportedCountries())
                .serviceOptions(carrier.getServiceOptions())
                .createdAt(carrier.getCreatedAt())
                .updatedAt(carrier.getUpdatedAt())
                .build();
    }
} 